package cn.jiyun.student.service.impl;

import cn.jiyun.student.dao.StudentDao;
import cn.jiyun.student.pojo.AdchannelVo;
import cn.jiyun.student.pojo.Student;
import cn.jiyun.student.service.StudentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;

    @Override
    public AdchannelVo add(Student student) {
        studentDao.insert(student);
        AdchannelVo adchannelVo = new AdchannelVo();
        adchannelVo.setCode(2000);
        adchannelVo.setMsg("学生添加成功");
        return adchannelVo;

    }

    @Override
    public List<Student> findById(Integer cid) {
        LambdaQueryWrapper<Student> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Student::getCid,cid);
        return studentDao.selectList(wrapper);
    }

    @Override
    public AdchannelVo delById(Integer cid) {
        LambdaQueryWrapper<Student> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Student::getCid,cid);
        studentDao.delete(wrapper);
        AdchannelVo adchannelVo = new AdchannelVo();
        adchannelVo.setCode(2000);
        adchannelVo.setMsg("删除成功");
        return adchannelVo;
    }
}
